package com.ruoyi.controller.middlesign.view;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.service.middlesign.MiddlesignDayService;
import com.ruoyi.service.middlesign.MiddlesignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @author zeo
 * @explain 手动每日发送
 * @date 2021/3/23 11:09
 */
@Controller
@RequestMapping("/middlesignDay")
public class MiddlesignDayController extends BaseController {

    @Autowired
    MiddlesignDayService middlesignDayService;

    @Autowired
    MiddlesignService middlesignService;

    private String prefix = "middlesign/day";

    @GetMapping()
    public String middlesignDay(ModelMap mmap) {
        return prefix + "/middlesignday";
    }

    @RequestMapping("/getMiddlesCreditDayList")
    @ResponseBody
    public TableDataInfo getMiddlesCreditDayList(){
        return getDataTable(middlesignDayService.findMiddlesCreditDaySendList());
    }

    @RequestMapping("/findStockDataAccounts")
    @ResponseBody
    public TableDataInfo findStockDataAccounts(@RequestParam Map map){
        middlesignDayService.insertStockDataAccounts(map);
        return getDataTable(middlesignDayService.findStockDataAccounts(map));
    }

    @RequestMapping("/findStockDataPayment")
    @ResponseBody
    public TableDataInfo findStockDataPayment(@RequestParam Map map){
        middlesignDayService.insertStockDataPayment(map);
        return getDataTable(middlesignDayService.findStockDataPayment(map));
    }

    @RequestMapping("/findStockSupplierAccount")
    @ResponseBody
    public TableDataInfo findStockSupplierAccount(@RequestParam Map map){
        String CREDIT_NAME = map.get("CREDITNAME").toString();
        middlesignService.insertStockSupplierAccount(CREDIT_NAME);
        return getDataTable(middlesignDayService.findStockSupplierAccount(map));
    }


    @RequestMapping("/findReconciliationData")
    @ResponseBody
    public TableDataInfo findReconciliationData(@RequestParam Map map){
        middlesignDayService.insertReconciliationData(map);
        return getDataTable(middlesignDayService.findReconciliationData(map));
    }
}
